<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="com.total.reporting.presentation.*,com.total.reporting.dao.*"%>
    
  <%@ include file="accessControl.jsp"%>
<%


if(request.getParameter("ok")!=null || request.getParameter("del")!=null){%>
	<jsp:useBean id="refList" class="com.total.reporting.dao.RefList" scope="page"></jsp:useBean>
	<jsp:setProperty property="id" name="refList" param="id"/>
	<jsp:setProperty property="name" name="refList" param="name"/>
	<jsp:setProperty property="type" name="refList" param="type"/>
	<jsp:setProperty property="parentType" name="refList" param="parentType"/>
	<jsp:setProperty property="orderNum" name="refList" param="orderNum"/>
	
	

<%
String delete=request.getParameter("del");
if(delete!=null && delete.equals("true")){
	 RefListController.delete(session,refList);
	 
	 
	 
}
else{

//System.out.println(refList.getId());
if(refList.getId()==-1){
String id=""+RefListController.saveRefList(session,refList);
}
else{
	RefListController.updateRefList(session,refList);
	
	
}
}
	
//request.setAttribute("id",id);
request.getRequestDispatcher("refListList.jsp").forward(request,response);




}else{	
	RefList refList=new RefList();
	String id = request.getParameter("id");
	if(id==null)
		id=(String)request.getAttribute("id");
	if(id!=null){
		 refList = RefListController.getRefListById(id);
		
	
	}
	else{
		refList.setId(-1);
	}
	
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>New RefListes</title>
<LINK rel="stylesheet" type="text/css" href="style.css" />
<script>
 function deleteItem(){
	 if( confirm('confirmez la suppression')){
		 document.forms[0].del.value='true';
		 document.forms[0].submit();
	 }
		 
		 
	 
 }
</script>
</head>
<body>
<form>
<input type="hidden" name="id" value="<%=refList.getId()%>"/>
<input type="hidden" name="del" value="false"/>
<span class="title" > Listes de reference</span>
<br></br>
<table>
<tr>
<td>nom</td><td><input name="name" size="80" value="<%=refList.getName()%>"></input></td>
</tr><tr>
<td>type</td><td><input name="type" size="80" value="<%=refList.getType()%>"></input></td>
</tr><tr>
<td>type parent</td><td><input name="parentType" size="80" value="<%=refList.getParentType()%>"></input></td>
</tr><tr>
<td>numero ordre</td><td><input name="orderNum" size="80" value="<%=refList.getOrderNum()%>"></input></td>
</tr>



</tr>

</table>
<input type="submit" name="ok" value="Enregistrer"></input>
&nbsp;
<%if(refList.getId()>-1){ %>
<input type="button" name="delete" onclick="deleteItem()" value="Supprimer"></input>
<%} %>
</form>
</body>
</html>
<%}%>